package com.yanqu.road.entity.activity.hsisland.config;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.hsisland.HsIslandPosition;
import com.yanqu.road.entity.activity.sonhai.config.SonHaiConfig;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.utils.MapHelper;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class HsIslandConfig {

    private static Logger logger = LogManager.getLogger(SonHaiConfig.class.getName());

    // 活动信息
    private ActivityInfo activityInfo;

    //基础配置MAP
    private Map<String, ActivityConfig> activityConfigMap;

    //商品配置MAP
    private Map<Integer, MallInfo> mallInfoMap;

    //船升级配置MAP
    private Map<Integer, HsIslandBoatConfig> boatConfigMap;

    //岛配置MAP
    private Map<Integer, HsIslandIslandConfig> islandConfigMap;

    //事件配置MAP
    private Map<Integer, HsIslandEventConfig> eventConfigMap;

    //pve怪配置MAP
    private Map<Integer, HsIslandPveConfig> pveConfigMap;

    //PVP结算配置MAP
    private Map<Integer, HsIslandDuelConfig> duelConfigMap;
    private Map<Integer, HsIslandDuelConfig> winNumDuelConfigMap;//key: 连胜次数

    //宝库配置MAP
    private  Map<Integer, HsIslandBoxConfig> boxConfigMap;

    //2选1配置MAP
    private Map<Integer, HsIslandChooseConfig> chooseConfigMap;

    //buff配置MAP
    private Map<Integer, HsIslandBuffConfig> buffConfigMap;

    //遗迹藏宝配置MAP
    private Map<Integer, HsIslandRelicConfig> relicConfigMap;

    //BOSS奖励配置MAP
    private Map<Integer, HsIslandBossRewardConfig> bossRewardConfigMap;

    //圣柱奖励配置MAP
    private Map<Integer, HsIslandGiftConfig> giftConfigMap;

    public int HSISLAND_ENERGY_ITEM_ID;//体力道具id（望穿秋水露）
    public int HSISLAND_INITIAL_ENERGY;//初始体力数量
    public int HSISLAND_ENERGY_MAX;//自然恢复体力数量上限
    public int HSISLAND_ENERGY_RECOVER;//自然恢复一点体力时间/秒
    public int HSISLAND_INITIAL_DOLL_ID;//初始小人形象道具id
    public Map<Integer, Integer> HSISLAND_ENERGY_CONSUME;//单次探索消耗体力数量(海域层数;体力|海域层数；体力）
    public int maxExploreEnergy;//最大探索体力
    public int HSISLAND_END_TIME_OF_EACH_DAY;//每日结束探索时间
    public int HSISLAND_OPEN_TIME_OF_EACH_DAY;//每日开启探索时间
    public int HSISLAND_POWER_PATRONS_NUM;//计算魂力的门客数量（前x名）
    public List<Integer> HSISLAND_POWER_PARAM;//玩家魂力计算方式（开根参数4【(赚钱/参数1+参数3)^参数2*(玩家vip*参数6+参数5）】）
    public int HSISLAND_DONATE_ITEM_ID;//捐献道具id(深海沉银)
    public int HSISLAND_INITIAL_DOUBLE_DONATE_NUM;//初始双倍捐献次数
    public int HSISLAND_ADD_DOUBLE_DONATE_NUM;//每新到一层增加的双倍捐献次数
    public String HSISLAND_DONATE_REWARD;//单次捐献奖励
    public int HSISLAND_DONATE_ADD_PROGRESS;//单次捐献增加进度
    public int HSISLAND_PVE_INITIAL_INVITE_TIMES;//初始可被邀请次数
    public int HSISLAND_PVE_INVITE_TIMES_RECOVER;//每消耗x体力恢复一次邀请次数
    public int HSISLAND_PVE_PROTECT_TIME;//PVE事件初始保护时间/秒（时间内仅发现者可以攻击）
    public int HSISLAND_PVE_ENERGY_INCREASE;//PVE每次攻击递增体力消耗量
    public int HSISLAND_PVE_INITIAL_ASSIST_TIMES;//初始可协助次数
    public int HSISLAND_PVE_ASSIST_TIMES_RECOVER;//每消耗x体力恢复一次协助次数
    public Map<Integer, Map<Integer, Integer>> HSISLAND_PVE_LARGE_MONSTER_PARAM;//四格怪对周围格权重赋值参数（海域层数,a;b;c;d;e|海域层数,a;b;c;d;e)，k:层，k:距离
    public List<Integer> HSISLAND_PVP_RANGE;//魂师连战排到的商会名次上下范围
    public int HSISLAND_PVP_FAULT_TOLERANT;//魂师连战PVP容错（当生成的商会人员数据小于参数时，重新roll事件）
    public String HSISLAND_PVP_BASIS_REWARD;//魂师连战PVP基础奖励
    public long HSISLAND_PVP_BASIS_SCORE;//魂师连战PVP基础积分
    public List<Integer> HSISLAND_PVP_SCORE_PARAM;//魂师连战PVP倍率参数
    public int HSISLAND_FOUND_BOX_FREE_TIMES;//发现宝库事件玩家额外免费次数
    public int HSISLAND_BOX_TIMES;//宝库事件正常玩家可领取次数
    public int HSISLAND_BOX_CONSUME_ENERGY;//宝库事件玩家首次处理是否消耗体力（1表示是，0表示否）是的话消耗海域体力值
    public List<Integer> HSISLAND_HOLY_PILLARS_ADD_PROGRESS;//圣柱试炼增加战意参数（x秒;增加的战意值）
    public List<List<Long>> HSISLAND_HOLY_PILLARS_BOSS_NEED_PROGRESS;//boss出现需求的战意值（活动跨服的平均跨服时长，战意值） 取大于等于
    public List<Integer> HSISLAND_HOLY_PILLARS_BOSS_POWER_PARAM_1;//圣柱试炼玩家分层系数配置
    public List<Integer> HSISLAND_HOLY_PILLARS_BOSS_POWER_PARAM_2;//圣柱试炼BOSS血量对应玩家分层战力系数配置
    public int HSISLAND_HOLY_PILLARS_INITIAL_ENERGY;//圣柱试炼初始体力数量
    public int HSISLAND_HOLY_PILLARS_NOTICE_TIME;//圣柱试炼boss公告时间（配置时间后开打）
    public List<Integer> HSISLAND_EXTRA_HOLY_PILLARS_ENERGY_PARAM;//额外圣柱精力增加参数（爬海域层数;增加的精力数量）
    public int HSISLAND_HOLY_PILLARS_RECOVER_TIME;//圣柱试炼精力耗尽需补充时间（秒）
    public int HSISLAND_HOLY_PILLARS_FIGHT_CONSUME;//圣柱试炼单次战斗消耗体力数量
    public int HSISLAND_HOLY_PILLARS_ENEMY_MARK_TIME;//圣柱试炼敌对玩家标记时间
    public List<Integer> HSISLAND_HOLY_PILLARS_BOSS_ORDER;//圣柱BOSS出现的顺序
    public int HSISLAND_HOLY_PILLARS_PLAYER_ADD_PROGRESS;  //  圣柱试炼玩家消耗单点体力增加的进度值
    public int HSISLAND_HOLY_PILLARS_DECREASE_HP_PARAM; // 圣柱试炼扣血倍率参数（=rounddown(己方魂力/敌方魂力,1)*参数)
    public int HSISLAND_HOLY_PILLARS_DECREASE_HP_MAX;   // 圣柱试炼扣血最大值
    public List<Integer> HSISLAND_HOLY_PILLARS_ATTACK_PARAM;      // 圣柱试炼可攻击玩家的魂力区间
    public List<Integer> HSISLAND_ATTACK_CD;        // 普通事件怪的攻击间隔|boss的攻击间隔(秒)
    public List<Integer> HSISLAND_KEY_APPEAR_PARAM;//单个岛屿海神之心钥匙出现参数（千分比是完成事件数/总事件数）
    public int HSISLAND_KEY_GET_SCORE;//海神之心获取积分
    public Map<Integer, Integer> HSISLAND_KEY_WEIGHT_INCREASE;//海神之心权重提高参数（探索千分比，海神之心提高的千分比|探索千分比，海神之心提高的千分比）
    public List<Integer> HSISLAND_KEY_GUARANTEE_PARAM;//海神之心保底参数
    public int HSISLAND_LIGHT_LATTICE_PARAM;//明灯事件照亮格子参数（边长）
    public List<Integer> HSISLAND_CHOOSE_SCORE_PARAM;//奇遇事件积分奖励参数（正确选项积分|错误选项积分）
    public List<Integer> HSISLAND_RELIC_CONSUME;//遗迹藏宝消耗体力数（第一次；第二次；第三次）
    public Property HSISLAND_RELIC_SHOW_REWARD;//遗迹藏宝宝箱展示奖励
    public int HSISLAND_PERSON_RECORD_LIMIT;//海神岛--个人日志记录上限
    public int HSISLAND_GUILD_RECORD_LIMIT;//海神岛--商会日志记录上限
    public int HSISLAND_DUEL_GUILD_NOTICE;//魂师对决上商会公告需求连胜次数
    public Property HSISLAND_FAST_FUNCTION_OPEN_CONSUME;//海神岛--打理解锁条件解锁消耗
    public int HSISLAND_FAST_FUNCTION_OPEN_COND;//海神岛--打理解锁条件（海神积分最小值)
    public int HSISLAND_FAST_FUNCTION_LATTICE_PARAM;//批量探索（边长）
    public int SHOW_PARTON_GET;//门客招募商店类型
    public int HSISLAND_MAP_GENERATE_PARAM;//地图权重生成模板量（取方差较优解）
    public int HSISLAND_PVE_LARGE_MONSTER_GENERATE;//4格事件生成最大递归次数

    public HsIslandConfig(ActivityInfo activityInfo,
                          Map<String, ActivityConfig> activityConfigMap,
                          Map<Integer, MallInfo> mallInfoMap,
                          Map<Integer, HsIslandBoatConfig> boatConfigMap,
                          Map<Integer, HsIslandIslandConfig> islandConfigMap,
                          Map<Integer, HsIslandEventConfig> eventConfigMap,
                          Map<Integer, HsIslandPveConfig> pveConfigMap,
                          Map<Integer, HsIslandDuelConfig> duelConfigMap,
                          Map<Integer, HsIslandBoxConfig> boxConfigMap,
                          Map<Integer, HsIslandChooseConfig> chooseConfigMap,
                          Map<Integer, HsIslandBuffConfig> buffConfigMap,
                          Map<Integer, HsIslandRelicConfig> relicConfigMap,
                          Map<Integer, HsIslandBossRewardConfig> bossRewardConfigMap,
                          Map<Integer, HsIslandGiftConfig> giftConfigMap) {
        this.activityInfo = activityInfo;
        this.activityConfigMap = activityConfigMap;
        this.mallInfoMap = mallInfoMap;
        this.boatConfigMap = boatConfigMap;
        this.islandConfigMap = islandConfigMap;
        this.eventConfigMap = eventConfigMap;
        this.pveConfigMap = pveConfigMap;
        this.duelConfigMap = duelConfigMap;
        this.boxConfigMap = boxConfigMap;
        this.chooseConfigMap = chooseConfigMap;
        this.buffConfigMap = buffConfigMap;
        this.relicConfigMap = relicConfigMap;
        this.bossRewardConfigMap = bossRewardConfigMap;
        this.giftConfigMap = giftConfigMap;
        //解析winNumDuelConfigMap
        Map<Integer, HsIslandDuelConfig> tmpWinNumDuelConfigMap = new ConcurrentHashMap<>();
        for (HsIslandDuelConfig duelConfig : duelConfigMap.values()) {
            String[] victoryNumArr = duelConfig.getVictoryNum().split("\\|");
            int start = Integer.parseInt(victoryNumArr[0]);
            int end = Integer.parseInt(victoryNumArr[1]);
            for (int i = start; i <= end; i++) {
                tmpWinNumDuelConfigMap.put(i, duelConfig);
            }
        }
        this.winNumDuelConfigMap = tmpWinNumDuelConfigMap;
        //config配置参数
        this.parseConfig(activityConfigMap);
    }

    /**
     * 解析配置参数
     * @param activityConfigMap
     */
    private void parseConfig(Map<String, ActivityConfig> activityConfigMap) {
        this.HSISLAND_ENERGY_ITEM_ID = activityConfigMap.get("HSISLAND_ENERGY_ITEM_ID").getIntValue();
        this.HSISLAND_INITIAL_ENERGY = activityConfigMap.get("HSISLAND_INITIAL_ENERGY").getIntValue();
        this.HSISLAND_ENERGY_MAX = activityConfigMap.get("HSISLAND_ENERGY_MAX").getIntValue();
        this.HSISLAND_ENERGY_RECOVER = activityConfigMap.get("HSISLAND_ENERGY_RECOVER").getIntValue();
        this.HSISLAND_INITIAL_DOLL_ID = activityConfigMap.get("HSISLAND_INITIAL_DOLL_ID").getIntValue();
        this.HSISLAND_ENERGY_CONSUME = StringUtils.parseStringToMap(activityConfigMap.get("HSISLAND_ENERGY_CONSUME").getValue(), "\\|", ";");
        Map.Entry<Integer, Integer> lastEntry = MapHelper.getLastEntry(this.HSISLAND_ENERGY_CONSUME);
        if (lastEntry != null) {
            this.maxExploreEnergy = lastEntry.getValue();
        }
        this.HSISLAND_END_TIME_OF_EACH_DAY = activityConfigMap.get("HSISLAND_END_TIME_OF_EACH_DAY").getIntValue();
        this.HSISLAND_OPEN_TIME_OF_EACH_DAY = activityConfigMap.get("HSISLAND_OPEN_TIME_OF_EACH_DAY").getIntValue();
        this.HSISLAND_POWER_PATRONS_NUM = activityConfigMap.get("HSISLAND_POWER_PATRONS_NUM").getIntValue();
        this.HSISLAND_POWER_PARAM = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_POWER_PARAM").getValue(), "\\|");
        this.HSISLAND_DONATE_ITEM_ID = activityConfigMap.get("HSISLAND_DONATE_ITEM_ID").getIntValue();
        this.HSISLAND_INITIAL_DOUBLE_DONATE_NUM = activityConfigMap.get("HSISLAND_INITIAL_DOUBLE_DONATE_NUM").getIntValue();
        this.HSISLAND_ADD_DOUBLE_DONATE_NUM = activityConfigMap.get("HSISLAND_ADD_DOUBLE_DONATE_NUM").getIntValue();
        this.HSISLAND_DONATE_REWARD = activityConfigMap.get("HSISLAND_DONATE_REWARD").getValue();
        this.HSISLAND_DONATE_ADD_PROGRESS = activityConfigMap.get("HSISLAND_DONATE_ADD_PROGRESS").getIntValue();
        this.HSISLAND_PVE_INITIAL_INVITE_TIMES = activityConfigMap.get("HSISLAND_PVE_INITIAL_INVITE_TIMES").getIntValue();
        this.HSISLAND_PVE_INVITE_TIMES_RECOVER = activityConfigMap.get("HSISLAND_PVE_INVITE_TIMES_RECOVER").getIntValue();
        this.HSISLAND_PVE_PROTECT_TIME = activityConfigMap.get("HSISLAND_PVE_PROTECT_TIME").getIntValue();
        this.HSISLAND_PVE_ENERGY_INCREASE = activityConfigMap.get("HSISLAND_PVE_ENERGY_INCREASE").getIntValue();
        this.HSISLAND_PVE_INITIAL_ASSIST_TIMES = activityConfigMap.get("HSISLAND_PVE_INITIAL_ASSIST_TIMES").getIntValue();
        this.HSISLAND_PVE_ASSIST_TIMES_RECOVER = activityConfigMap.get("HSISLAND_PVE_ASSIST_TIMES_RECOVER").getIntValue();
        this.HSISLAND_PVP_RANGE = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_PVP_RANGE").getValue(), "\\|");
        this.HSISLAND_PVP_FAULT_TOLERANT = activityConfigMap.get("HSISLAND_PVP_FAULT_TOLERANT").getIntValue();
        this.HSISLAND_PVP_BASIS_REWARD = activityConfigMap.get("HSISLAND_PVP_BASIS_REWARD").getValue();
        this.HSISLAND_PVP_BASIS_SCORE = activityConfigMap.get("HSISLAND_PVP_BASIS_SCORE").getLongValue();
        this.HSISLAND_PVP_SCORE_PARAM = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_PVP_SCORE_PARAM").getValue(), "\\|");
        this.HSISLAND_FOUND_BOX_FREE_TIMES = activityConfigMap.get("HSISLAND_FOUND_BOX_FREE_TIMES").getIntValue();
        this.HSISLAND_BOX_TIMES = activityConfigMap.get("HSISLAND_BOX_TIMES").getIntValue();
        this.HSISLAND_BOX_CONSUME_ENERGY = activityConfigMap.get("HSISLAND_BOX_CONSUME_ENERGY").getIntValue();
        this.HSISLAND_HOLY_PILLARS_ADD_PROGRESS = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_HOLY_PILLARS_ADD_PROGRESS").getValue(), ";");

        List<List<Long>> tmpProgressList = new ArrayList<>();
        List<String> pillarsBossNeedProgressStr = StringUtils.stringToStringList(activityConfigMap.get("HSISLAND_HOLY_PILLARS_BOSS_NEED_PROGRESS").getValue(), "\\|");
        for (String s : pillarsBossNeedProgressStr) {
            List<Long> list = new ArrayList<>();
            String[] split = s.split(",");
            list.add(Long.parseLong(split[0]));
            list.add(Long.parseLong(split[1]));
            tmpProgressList.add(list);
        }
        this.HSISLAND_HOLY_PILLARS_BOSS_NEED_PROGRESS = tmpProgressList;

        this.HSISLAND_HOLY_PILLARS_BOSS_POWER_PARAM_1 = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_HOLY_PILLARS_BOSS_POWER_PARAM_1").getValue(), "\\|");
        this.HSISLAND_HOLY_PILLARS_BOSS_POWER_PARAM_2 = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_HOLY_PILLARS_BOSS_POWER_PARAM_2").getValue(), "\\|");
        this.HSISLAND_HOLY_PILLARS_INITIAL_ENERGY = activityConfigMap.get("HSISLAND_HOLY_PILLARS_INITIAL_ENERGY").getIntValue();
        this.HSISLAND_HOLY_PILLARS_NOTICE_TIME = activityConfigMap.get("HSISLAND_HOLY_PILLARS_NOTICE_TIME").getIntValue();
        this.HSISLAND_EXTRA_HOLY_PILLARS_ENERGY_PARAM = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_EXTRA_HOLY_PILLARS_ENERGY_PARAM").getValue(), ";");
        this.HSISLAND_HOLY_PILLARS_RECOVER_TIME = activityConfigMap.get("HSISLAND_HOLY_PILLARS_RECOVER_TIME").getIntValue();
        this.HSISLAND_HOLY_PILLARS_FIGHT_CONSUME = activityConfigMap.get("HSISLAND_HOLY_PILLARS_FIGHT_CONSUME").getIntValue();
        this.HSISLAND_HOLY_PILLARS_ENEMY_MARK_TIME = activityConfigMap.get("HSISLAND_HOLY_PILLARS_ENEMY_MARK_TIME").getIntValue();
        this.HSISLAND_HOLY_PILLARS_BOSS_ORDER = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_HOLY_PILLARS_BOSS_ORDER").getValue(), ";");
        this.HSISLAND_HOLY_PILLARS_PLAYER_ADD_PROGRESS = activityConfigMap.get("HSISLAND_HOLY_PILLARS_PLAYER_ADD_PROGRESS").getIntValue();
        this.HSISLAND_HOLY_PILLARS_DECREASE_HP_PARAM = activityConfigMap.get("HSISLAND_HOLY_PILLARS_DECREASE_HP_PARAM").getIntValue();
        this.HSISLAND_HOLY_PILLARS_DECREASE_HP_MAX = activityConfigMap.get("HSISLAND_HOLY_PILLARS_DECREASE_HP_MAX").getIntValue();
        this.HSISLAND_HOLY_PILLARS_ATTACK_PARAM = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_HOLY_PILLARS_ATTACK_PARAM").getValue(), "\\|");
        this.HSISLAND_ATTACK_CD = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_ATTACK_CD").getValue(), "\\|");
        this.HSISLAND_KEY_APPEAR_PARAM = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_KEY_APPEAR_PARAM").getValue(), "\\|");
        this.HSISLAND_KEY_GET_SCORE = activityConfigMap.get("HSISLAND_KEY_GET_SCORE").getIntValue();
        String[] keyWeightIncrease = activityConfigMap.get("HSISLAND_KEY_WEIGHT_INCREASE").getValue().split("\\|");
        Map<Integer, Integer> keyWeightIncreaseMap = new LinkedHashMap<>();
        for (String item : keyWeightIncrease) {
            String[] split = item.split(",");
            keyWeightIncreaseMap.put(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
        }
        this.HSISLAND_KEY_WEIGHT_INCREASE = keyWeightIncreaseMap;
        this.HSISLAND_KEY_GUARANTEE_PARAM = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_KEY_GUARANTEE_PARAM").getValue(), "\\|");
        this.HSISLAND_LIGHT_LATTICE_PARAM = activityConfigMap.get("HSISLAND_LIGHT_LATTICE_PARAM").getIntValue();
        this.HSISLAND_CHOOSE_SCORE_PARAM =  StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_CHOOSE_SCORE_PARAM").getValue(), "\\|");
        this.HSISLAND_RELIC_CONSUME = StringUtils.stringToIntegerList(activityConfigMap.get("HSISLAND_RELIC_CONSUME").getValue(), ";");
        this.HSISLAND_RELIC_SHOW_REWARD = PropertyHelper.parseStringToProperty(activityConfigMap.get("HSISLAND_RELIC_SHOW_REWARD").getValue());
        this.HSISLAND_PERSON_RECORD_LIMIT = activityConfigMap.get("HSISLAND_PERSON_RECORD_LIMIT").getIntValue();
        this.HSISLAND_GUILD_RECORD_LIMIT = activityConfigMap.get("HSISLAND_GUILD_RECORD_LIMIT").getIntValue();
        this.HSISLAND_DUEL_GUILD_NOTICE = activityConfigMap.get("HSISLAND_DUEL_GUILD_NOTICE").getIntValue();
        this.HSISLAND_FAST_FUNCTION_OPEN_CONSUME = PropertyHelper.parseStringToProperty(activityConfigMap.get("HSISLAND_FAST_FUNCTION_OPEN_CONSUME").getValue());
        this.HSISLAND_FAST_FUNCTION_OPEN_COND = activityConfigMap.get("HSISLAND_FAST_FUNCTION_OPEN_COND").getIntValue();
        this.HSISLAND_FAST_FUNCTION_LATTICE_PARAM = activityConfigMap.get("HSISLAND_FAST_FUNCTION_LATTICE_PARAM").getIntValue();
        this.SHOW_PARTON_GET = activityConfigMap.get("SHOW_PARTON_GET").getIntValue();
        this.HSISLAND_MAP_GENERATE_PARAM = activityConfigMap.get("HSISLAND_MAP_GENERATE_PARAM").getIntValue();
        this.HSISLAND_PVE_LARGE_MONSTER_GENERATE = activityConfigMap.get("HSISLAND_PVE_LARGE_MONSTER_GENERATE").getIntValue();

        //解析富集度参数MAP
        String[] pveLargeMonsterParamArr = activityConfigMap.get("HSISLAND_PVE_LARGE_MONSTER_PARAM").getValue().split("\\|");
        Map<Integer, Map<Integer, Integer>> pveLargeMonsterParamMap = new LinkedHashMap<>();
        for (String pveLargeMonsterParam : pveLargeMonsterParamArr) {
            String[] itemArr = pveLargeMonsterParam.split(",");
            int floodNum = Integer.parseInt(itemArr[0]);
            Map<Integer, Integer> distanceMap = new LinkedHashMap<>();
            String[] distanceArr = itemArr[1].split(";");
            for (int i = 0; i < distanceArr.length; i++) {
                distanceMap.put(i, Integer.parseInt(distanceArr[i]));
            }
            pveLargeMonsterParamMap.put(floodNum, distanceMap);
        }
        this.HSISLAND_PVE_LARGE_MONSTER_PARAM = pveLargeMonsterParamMap;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public Map<String, ActivityConfig> getActivityConfigMap() {
        return activityConfigMap;
    }

    public Map<Integer, MallInfo> getMallInfoMap() {
        return mallInfoMap;
    }

    public Map<Integer, HsIslandBoatConfig> getBoatConfigMap() {
        return boatConfigMap;
    }

    public HsIslandBoatConfig getBoatConfig(int id) {
        return boatConfigMap.get(id);
    }

    public Map<Integer, HsIslandIslandConfig> getIslandConfigMap() {
        return islandConfigMap;
    }

    public HsIslandIslandConfig getIslandConfig(int id) {
        return islandConfigMap.get(id);
    }

    public Map<Integer, HsIslandEventConfig> getEventConfigMap() {
        return eventConfigMap;
    }

    public HsIslandEventConfig getEventConfig(int id) {
        return eventConfigMap.get(id);
    }

    public Map<Integer, HsIslandPveConfig> getPveConfigMap() {
        return pveConfigMap;
    }

    public HsIslandPveConfig getPveConfig(int id) {
        return pveConfigMap.get(id);
    }

    public Map<Integer, HsIslandDuelConfig> getDuelConfigMap() {
        return duelConfigMap;
    }

    public Map<Integer, HsIslandDuelConfig> getWinNumDuelConfigMap() {
        return winNumDuelConfigMap;
    }

    public Map<Integer, HsIslandBoxConfig> getBoxConfigMap() {
        return boxConfigMap;
    }

    public HsIslandBoxConfig getBoxConfig(int id) {
        return boxConfigMap.get(id);
    }

    public Map<Integer, HsIslandChooseConfig> getChooseConfigMap() {
        return chooseConfigMap;
    }

    public HsIslandChooseConfig getChooseConfig(int id) {
        return chooseConfigMap.get(id);
    }

    public Map<Integer, HsIslandBuffConfig> getBuffConfigMap() {
        return buffConfigMap;
    }

    public HsIslandBuffConfig getBuffConfig(int id) {
        return buffConfigMap.get(id);
    }

    public Map<Integer, HsIslandRelicConfig> getRelicConfigMap() {
        return relicConfigMap;
    }

    public HsIslandRelicConfig getRelicConfig(int id) {
        return relicConfigMap.get(id);
    }

    public Map<Integer, HsIslandBossRewardConfig> getBossRewardConfigMap() {
        return bossRewardConfigMap;
    }

    public HsIslandBossRewardConfig getBossRewardConfig(int id) {
        return bossRewardConfigMap.get(id);
    }

    public Map<Integer, HsIslandGiftConfig> getGiftConfigMap() {
        return giftConfigMap;
    }

    public HsIslandGiftConfig getGiftConfig(int id) {
        return giftConfigMap.get(id);
    }

    /**
     * 判断是否在每日战斗时间段
     * @return
     */
    public boolean checkInDailyBattleTime() {
        int hour = DateHelper.getHours();
        if(hour < HSISLAND_OPEN_TIME_OF_EACH_DAY || hour >= HSISLAND_END_TIME_OF_EACH_DAY){
            return false;
        }
        return true;
    }

    /**
     * 根据权重随出3个岛
     * @return
     */
    public List<Integer> randomIslandIdList() {
        Map<Integer, Integer> wMap = new HashMap<>();
        Map<Integer, Set<Integer>> mapTypeMap = new HashMap<>();
        for (HsIslandIslandConfig islandConfig : this.islandConfigMap.values()) {
            wMap.put(islandConfig.getId(), islandConfig.getWeight());
            Set<Integer> idSet = mapTypeMap.computeIfAbsent(islandConfig.getMapType(), k -> new HashSet<>());
            idSet.add(islandConfig.getId());
        }
        //随出3个岛
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            int islandId = RandomHelper.getRandomKeyByWeight(wMap);
            list.add(islandId);
            //移除同一mapType的模版
            HsIslandIslandConfig islandConfig = this.getIslandConfig(islandId);
            if (islandConfig != null) {
                Set<Integer> idSet = mapTypeMap.get(islandConfig.getMapType());
                for (int removeId : idSet) {
                    wMap.remove(removeId);
                }
            }
            if (wMap.isEmpty()) {
                break;
            }
        }
        //如果数量小于3个，补足一下岛屿
        int addNum = 3 - list.size();
        if (addNum > 0) {
            for (int i = 0; i < addNum; i++) {
                for (HsIslandIslandConfig islandConfig : this.islandConfigMap.values()) {
                    if (!list.contains(islandConfig.getId())) {
                        list.add(islandConfig.getId());
                        break;
                    }
                }
            }
        }
        return list;
    }

    /**
     * 获取岛屿出生点
     * @param islandId
     * @return
     */
    public HsIslandPosition getIslandBornPosition(int islandId) {
        HsIslandIslandConfig islandConfig = this.getIslandConfig(islandId);
        if (islandConfig != null) {
            String position = islandConfig.getRandomBornPosition();
            if (!StringUtils.isNullOrEmpty(position)) {
                String[] pos = position.split(",");
                int x = Integer.parseInt(pos[0]);
                int y = Integer.parseInt(pos[1]);
                return new HsIslandPosition(x, y);
            }
        }
        return null;
    }

    /**
     * 获取探索的体力消耗
     * @param floorId
     * @return
     */
    public int getExploreEnergyCost(int floorId) {
        return this.HSISLAND_ENERGY_CONSUME.getOrDefault(floorId, this.maxExploreEnergy);
    }

    /**
     * 权重随机获取怪ID
     * @param type
     * @return
     */
    public int getWeightRandomMonsterId(int type) {
        Map<Integer, Integer> monsterWeightMap = new HashMap<>();
        for (HsIslandPveConfig pveConfig : this.pveConfigMap.values()) {
            if (pveConfig.getType() == type) {
                monsterWeightMap.put(pveConfig.getId(), pveConfig.getWeight());
            }
        }
        //权重随机
        return RandomHelper.getRandomKeyByWeight(monsterWeightMap);
    }

    /**
     * 随机一个2选1ID
     * @return
     */
    public int getRandomChooseConfigId() {
        Integer id = RandomHelper.getRandomElement(this.chooseConfigMap.keySet());
        if (id == null) {
            return 1;
        }
        return id;
    }

    /**
     * 权重随机获取BUFF
     * @return
     */
    public HsIslandBuffConfig getWeightRandomBuff() {
        Map<Integer, Integer> buffWeightMap = new HashMap<>();
        for (HsIslandBuffConfig buffConfig : this.buffConfigMap.values()) {
            buffWeightMap.put(buffConfig.getId(), buffConfig.getWeight());
        }
        int buffId = RandomHelper.getRandomKeyByWeight(buffWeightMap);
        return this.buffConfigMap.get(buffId);
    }

    /**
     * 获取下一只boss的Id
     *
     * @param bossNum 已生成的boss数量
     */
    public int getNextBossId(int bossNum) {
        if (this.HSISLAND_HOLY_PILLARS_BOSS_ORDER.isEmpty()) {
            return 0;
        }
        return this.HSISLAND_HOLY_PILLARS_BOSS_ORDER.get(bossNum % this.HSISLAND_HOLY_PILLARS_BOSS_ORDER.size());
    }

    /**
     * 获取船只等级
     * @param exp
     * @return
     */
    public int getBoatLevel(long exp) {
        int level = 1;
        for (HsIslandBoatConfig boatConfig : this.getBoatConfigMap().values()) {
            if (exp >= boatConfig.getExp() && boatConfig.getExp() != 0) {
                level++;
            }
        }
        return level;
    }

    /**
     * 获取当前最大的精力上限
     */
    public int getMaxPvpEnergy(int floorId) {
        int initPvpEnergy = this.HSISLAND_HOLY_PILLARS_INITIAL_ENERGY;
        // 计算下当前额外的上限
        int addPvpEnergy = ((floorId - 1) / this.HSISLAND_EXTRA_HOLY_PILLARS_ENERGY_PARAM.get(0)) * this.HSISLAND_EXTRA_HOLY_PILLARS_ENERGY_PARAM.get(1);
        return initPvpEnergy + addPvpEnergy;
    }

    /**
     * 按权重随机出圣柱馈赠奖励
     * @return
     */
    public HsIslandGiftConfig getWeightRandomGift() {
        Map<Integer, Integer> weightMap = new HashMap<>();
        for (HsIslandGiftConfig giftConfig : this.giftConfigMap.values()) {
            weightMap.put(giftConfig.getId(), giftConfig.getWeight());
        }
        int giftId = RandomHelper.getRandomKeyByWeight(weightMap);
        return this.giftConfigMap.get(giftId);
    }

    /**
     * 获取boss奖励
     * @param myRank 我的排名
     */
    public Property getBossReward(int myRank) {
        for (HsIslandBossRewardConfig rewardConfig : bossRewardConfigMap.values()) {
            List<Integer> rankRange = StringUtils.stringToIntegerList(rewardConfig.getRank(), "\\|");
            if (myRank >= rankRange.get(0) && myRank <= rankRange.get(1)) {
                return PropertyHelper.parseStringToProperty(rewardConfig.getReward());
            }
        }
        return null;
    }

    /**
     * 获取连胜倍率
     * @param winNum
     * @return
     */
    public int getPvpScoreRate(int winNum) {
        if (this.HSISLAND_PVP_SCORE_PARAM.size() > winNum) {
            return this.HSISLAND_PVP_SCORE_PARAM.get(winNum);
        }
        return 1000;
    }

    /**
     * 判断是否在活动期
     * @return
     */
    public boolean checkInActivityTime() {
        List<Integer> paramList = StringUtils.stringToIntegerList(activityInfo.getUnionGroup(), "\\|");
        int groupTime = paramList.get(3);
        //真正的能玩的时间
        long realBeginTime = this.activityInfo.getBeginTime() + groupTime * DateHelper.MINUTE_SECONDS;
        long now = System.currentTimeMillis() / 1000;
        return now >= realBeginTime && now <= activityInfo.getEndTime();
    }

    /**
     * 海神之心进入随机池最小探索进度千分比
     * @return
     */
    public int getKeyShowRate() {
        RandomHelper randomHelper = new RandomHelper();
        if (this.HSISLAND_KEY_APPEAR_PARAM != null && this.HSISLAND_KEY_APPEAR_PARAM.size() >= 2) {
            return randomHelper.next(this.HSISLAND_KEY_APPEAR_PARAM.get(0), this.HSISLAND_KEY_APPEAR_PARAM.get(1) + 1);
        }
        return 500;
    }

    /**
     * 获取海神之心必现最小探索进度千分比
     * @return
     */
    public int getKeyMustShowRate() {
        RandomHelper randomHelper = new RandomHelper();
        if (this.HSISLAND_KEY_GUARANTEE_PARAM != null && this.HSISLAND_KEY_GUARANTEE_PARAM.size() >= 2) {
            return randomHelper.next(this.HSISLAND_KEY_GUARANTEE_PARAM.get(0), this.HSISLAND_KEY_GUARANTEE_PARAM.get(1) + 1);
        }
        return 800;
    }

    /**
     * 获取海神之心命中增加的权重
     * @param exploreProgress
     * @return
     */
    public int getKeyShowAddWeight(int exploreProgress) {
        int result = 0;
        for (Map.Entry<Integer, Integer> entry : this.HSISLAND_KEY_WEIGHT_INCREASE.entrySet()) {
            int minExploreProgress = entry.getKey();
            int addWeight = entry.getValue();
            if (exploreProgress >= minExploreProgress) {
                result = addWeight;
            } else {
                break;
            }
        }
        return result;
    }

    /**
     * 获取富集度配置MAP
     * @param floodId
     * @return
     */
    public Map<Integer, Integer> getFjdConfigMap(int floodId) {
        Map<Integer, Integer> targetMap = new HashMap<>();
        for (Map.Entry<Integer, Map<Integer, Integer>> entry : this.HSISLAND_PVE_LARGE_MONSTER_PARAM.entrySet()) {
            int configFloodId = entry.getKey();
            Map<Integer, Integer> fjdConfigMap = entry.getValue();
            if (floodId >= configFloodId) {
                targetMap = fjdConfigMap;
            }
        }
        return targetMap;
    }
}
